package enc

import (
	"fmt"
	"gitee.com/ichub/goconfig/common/base/encrypt"
	"gitee.com/ichub/goconfig/common/ichubcontext"
	"gitee.com/ichub/goconfig/common/ichublog"
	"github.com/spf13/cobra"
)

func EncCmds() []*cobra.Command {
	ichublog.InitLogrus()
	var decCmd = &cobra.Command{
		Use:   "dec [flag]",
		Short: "dec password",
		Run: func(cmd *cobra.Command, args []string) {
			flag := cmd.Flags().Arg(0)
			ichubcontext.IchubClient.RegisterEncDec(encrypt.EncDecInst)

			pwd := encrypt.EncDecInst.AesDecBase64(flag)
			fmt.Println(pwd)
		},
	}

	var encCmd = &cobra.Command{
		Use:   "enc [flag]",
		Short: "enc password",
		Run: func(cmd *cobra.Command, args []string) {
			flag := cmd.Flags().Arg(0)
			pwd := encrypt.EncDecInst.AesEncBase64(flag)
			fmt.Println(pwd)
		},
	}
	return []*cobra.Command{decCmd, encCmd}

}
